package com.edgar.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 查看servlet线程
 * 
 * @author Edgar Zhang
 */
public class DemoServlet extends HttpServlet {
    /**
     * 序列化ID
     */
    private static final long serialVersionUID = 4759694681331916806L;
    private int i = 0;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
    	System.out.println(i ++);
        Enumeration enums = req.getParameterNames();
        while (enums.hasMoreElements()) {
            String key = (String) enums.nextElement();
            System.out.println(req.getParameter(key));
        }
        System.out.println(Thread.currentThread().getId());
        PrintWriter out = resp.getWriter();
        out.println(Thread.currentThread().getId());
    }

}
